﻿//
// Created by Freeman on 2022/4/13.
//

#ifndef DATA_STRUCTURE_REVIEW_EDGE_HPP
#define DATA_STRUCTURE_REVIEW_EDGE_HPP

#include <iostream>

#include "../Exceptions.hpp"

class Edge {
    friend class UndirectedListGraph;

    friend class DirectedListGraph;

    friend bool operator==(const Edge &edge1, const Edge &edge2);

    friend std::ostream &operator<<(std::ostream &out, const Edge &edge);

private:
    int tail = -1, head = -1; // tail -> head
    double weight = 1;
    bool directed = false;

public:
    Edge(int tail, int head, bool directed, double weight = 1) {
        if (head == tail) throw IllegalArgumentException();
        this->tail = tail;
        this->head = head;
        this->directed = directed;
        this->weight = weight;
    }

    Edge() = default;

    bool operator<(const Edge &other) const;

    bool operator>=(const Edge &other) const;

    bool operator>(const Edge &other) const;

    bool operator<=(const Edge &other) const;
};

#endif //DATA_STRUCTURE_REVIEW_EDGE_HPP
